<?php 

 $link = mysql_connect('localhost', 'kootenay', 'nonsense');
 if (!$link) {
  die ('Not connected : ' . mysql_error());
 }
 $db_selected = mysql_select_db('kootenay', $link);

 if (!$db_selected) {
  die ('Can\'t use foo : ' . mysql_error());
 }
 
 $query = "select album_id, label_id from ml_albums where label_id is not null";
 $result = mysql_query($query);
 while ($row = mysql_fetch_array($result))
 {
	 $album_id = $row[0];
	 echo "label id: ".$row[1];
	 
	 $aid_query = 'select company_name from ml_labels where label_id LIKE "'.$row[1].'"';
	 $aid_result = mysql_query($aid_query);
	 $aid_row = mysql_fetch_array($aid_result);
	 
	 
	 $update_query='update ml_albums set label ="'.$aid_row[0].'" where album_id ="'.$album_id . '"' ; echo $update_query;
	 $update_result = mysql_query($update_query); if ($update_result) echo "  - updated";
	 $a++;
 	echo "<br>";
 }
 
 echo "<br> total: $a";
?>